#include "Runnable_PCH.h"
#include "Runnable.h"

/*--------------------------------------------------------------------------*/

Runnable::Runnable(int argc, char** argv) :
	m_argc(argc),
	m_argv(argv)
{

}

/*--------------------------------------------------------------------------*/

Runnable::~Runnable()
{
	IScene			::DestroyInstance();
	IMesh			::DestroyInstance();
	IUserInterface	::DestroyInstance();
	IRenderer		::DestroyInstance();
	IInput			::DestroyInstance();
	IShell			::DestroyInstance();
	IKernel			::DestroyInstance();
	ILog			::DestroyInstance();
}

/*--------------------------------------------------------------------------*/

void Runnable::Loop()
{
	g_Kernel->InifityLoop();
}

/*--------------------------------------------------------------------------*/

void Runnable::Initialize()
{
	ILog			::CreateInstance();
	IKernel			::CreateInstance();
	IShell			::CreateInstance();
	IInput			::CreateInstance();
	IRenderer		::CreateInstance();
	IUserInterface	::CreateInstance();
	IMesh			::CreateInstance();
	IScene			::CreateInstance();

	EngineConfig conf;

	g_Kernel->CreateGameWindow(conf.GetTitle().c_str(), conf.GetWidth(), conf.GetHeight(), conf.GetFullscreen(), conf.GetVSync());
	g_Renderer->InitializeOpenGL(conf.GetWidth(), conf.GetHeight());
	g_UserInterface->InitializeUI(conf.GetWidth(), conf.GetHeight());
	g_Scene->InitializeScene();
}

/*--------------------------------------------------------------------------*/

